<?php
class OrderAction extends Action{
	public function index(){
		$db=M('order');
		import('ORG.Util.Page');
		$count=$db->where(array('status'=>1))->count('id');
		$page=new Page($count,10);
		$limit = $page->firstRow . ',' . $page->listRows;
		$result=$db->where(array('status'=>1))->field(array('id','number','consignee','address','total','status','time'))->limit($limit)->select();
		/*print_r($result);
		die;*/
		$this->result=$result;
		$this->page=$page->show();
		$this->display();
	}
	/**
	 * 订单详细列表
	 */
	public function orderList(){
		$oid=(int)$_GET['oid'];
		$db=D('OrderView');
		import('ORG.Util.Page');
		$count=$db->where(array('oid'=>$oid))->count();
		$page=new Page($count,10);
		$limit = $page->firstRow . ',' . $page->listRows;
		$result=$db->where(array('oid'=>$oid))->limit($limit)->select();
		$this->result=$result;
		$this->page=$page->show();
		$this->display();
	}
	//待发货订单显示
	public function waitOrder(){
		$db=M('order');
		import('ORG.Util.Page');
		$count=$db->where(array('status'=>2))->count('id');
		$page=new Page($count,10);
		$limit = $page->firstRow . ',' . $page->listRows;
		$result=$db->where(array('status'=>2))->field(array('id','number','consignee','address','total','status','time'))->limit($limit)->select();
		/*print_r($result);
		die;*/
		$this->result=$result;
		$this->page=$page->show();
		$this->display();
	}
	//已发货订单显示
	public function setOrder(){
		$db=M('order');
		import('ORG.Util.Page');
		$count=$db->where(array('status'=>3))->count('id');
		$page=new Page($count,10);
		$limit = $page->firstRow . ',' . $page->listRows;
		$result=$db->where(array('status'=>3))->field(array('id','number','consignee','address','total','status','time'))->limit($limit)->select();
		/*print_r($result);
		die;*/
		$this->result=$result;
		$this->page=$page->show();
		$this->display();
	}
	//已完成订单显示
	public function successOrder(){
		$db=M('order');
		import('ORG.Util.Page');
		$count=$db->where(array('status'=>4))->count('id');
		$page=new Page($count,10);
		$limit = $page->firstRow . ',' . $page->listRows;
		$result=$db->where(array('status'=>4))->field(array('id','number','consignee','address','total','status','time'))->limit($limit)->select();
		/*print_r($result);
		die;*/
		$this->result=$result;
		$this->page=$page->show();
		$this->display();
	}
	//手动发货
	public function set(){
		$oid=$_GET['oid'];
		$db=M('order');
		$rows=$db->data(array('status'=>3))->where(array('id'=>$oid))->save();
		if($rows){
			$this->success('发货成功');
		}else{
			$this->error('发货失败');
		}
	}

}
?>